

project(swidgets)

find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)

QT5_CREATE_TRANSLATION(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} swidgets_zh_CN.ts) 
file(GLOB SRCS CONFIGURE_DEPENDS *.cpp)

add_library(${PROJECT_NAME} SHARED
     ${SRCS}
     ${QM_FILES}
	 swidgets.qrc
)

target_compile_options(${PROJECT_NAME} PRIVATE -DS_WIDGETS_DLL)
target_link_libraries(${PROJECT_NAME} Qt::Widgets)

file(GLOB PLUG_SRC CONFIGURE_DEPENDS ./plugin/*.cpp)
add_library(swidgetsplugin SHARED
	${PLUG_SRC})
target_link_libraries(swidgetsplugin Qt::Widgets ${PROJECT_NAME})

if(WIN32)
	add_custom_command(TARGET swidgetsplugin
		POST_BUILD
		COMMAND "${CMAKE_COMMAND}" -E copy_if_different
			$<TARGET_FILE:swidgetsplugin>
			${QT_PLUGINS_PATH_WIN}/designer/)
endif()
